package com.geostar.constructionland.analyse.controller;

import com.geostar.constructionland.common.entity.response.ExtJsAjaxResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.ValidationException;

/**
 * @Author makoto_zhu
 * @Date 2020-11-13 03:58:23
 * @Description
 **/
@ControllerAdvice
public class MyControllerAdvice {

    /**
     * 捕捉验证处理
     *
     * @param ex
     * @return
     */
    @ResponseBody
    @ExceptionHandler(value = ValidationException.class)
    public ExtJsAjaxResponse errorHandler(ValidationException ex) {
        ex.printStackTrace();
        return ExtJsAjaxResponse.createByErrorMessage(ex.getCause().getMessage());
    }

}